﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Googler.DAL;
using System.Data.Objects;
using Googler.BLL;

namespace Googler
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
        }

        DataContext context;
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            context = new DataContext();

            var list = context.Keywords;
            keywordBindingSource.DataSource = new BindingAdapter<Keyword>(context,list);
            keywordBindingSource.ResetBindings(false);
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Save();
        }

        private void Save()
        {
            context.SaveChanges();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void keywordBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            Save();
        }        
    }
}
